using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.CodeDom.Compiler;

namespace NBusiness.CodeDom.Compiler
{
    [Serializable]
	public abstract class EntityGenerator : ICodeGenerator
	{
		public abstract EntityResourceFile[] GenerateFilesFromFamily(EntityCompilerParameters parameters, EntityRoot root);

        public event EventHandler<EntityBuildErrorEventArgs> Error;
        protected virtual void OnError(EntityBuildError error)
        {
            if (Error != null) Error(this, new EntityBuildErrorEventArgs(error));
        }

        #region ICodeGenerator Members

        public abstract string CreateEscapedIdentifier(string value);

        public abstract string CreateValidIdentifier(string value);

        public abstract void GenerateCodeFromCompileUnit(System.CodeDom.CodeCompileUnit e, TextWriter w, CodeGeneratorOptions o);

        public abstract void GenerateCodeFromExpression(System.CodeDom.CodeExpression e, TextWriter w, CodeGeneratorOptions o);

        public abstract void GenerateCodeFromNamespace(System.CodeDom.CodeNamespace e, TextWriter w, CodeGeneratorOptions o);

        public abstract void GenerateCodeFromStatement(System.CodeDom.CodeStatement e, TextWriter w, CodeGeneratorOptions o);

        public abstract void GenerateCodeFromType(System.CodeDom.CodeTypeDeclaration e, TextWriter w, CodeGeneratorOptions o);

        public abstract string GetTypeOutput(System.CodeDom.CodeTypeReference type);

        public abstract bool IsValidIdentifier(string value);

        public abstract bool Supports(GeneratorSupport supports);

        public abstract void ValidateIdentifier(string value);

        #endregion
    }
}
